package com.example.kotlintest.collection

import java.lang.StringBuilder

class Kt0801 {

fun collect(){
    var list = mutableListOf<String>("周一","周二","周三","周四")
    list.forEach {
        println(it)
    }
     var resultWith= with(StringBuilder()){
        for (day in list){
            append(day).append("*")
        }
        toString()
    }
    println("with:"+resultWith)

    var resultRun = StringBuffer().run {
        list.forEach {
            append("当日:$it").append("$")
        }
        toString()
    }
    println("run:"+resultRun)
    var resultApply=StringBuffer().apply {
        list.forEach {
            append(it).append("#")
        }
        toString()
    }
    println("apply:"+resultApply)

   var letResult=list.let {
       it.forEach {
        it;
       }
       list[0]
    }
    println("letResult:$letResult")//返回block最后一行结果

    var alseResult=list.also {
        it.forEach {
            it.length
        }
        list[0]
    }
    println("alsoResult:$alseResult")//不返回结果
}


}
fun main(){
    Kt0801().collect();
    println("*************************************************")
    println("hello")
    var a:Int=0;
    var b:Int =1;
    var b2: Int =a or b ;
    println(b2)


}